<template>
	<view class="orderManagement">
		<view class="tabs">
			<u-tabs :scrollable="false" :list="list" @click="on_tab"></u-tabs>
		</view>
		<view class="content">
			<view v-if="pageIndex == 0">
				<view class="inputValueBox">
					<u--input focus v-model="valueDataTwo" customStyle="background: #fff;" @confirm="on_confirm(1)"
						shape="circle" border="true" :adjustPosition="false" fontSize="14px"
						placeholder="订单号/子订单号/收货手机号/姓名/快递单号" prefixIcon="search"
						prefixIconStyle="font-size: 22px;color: #0000000;font-weight: 700;" />
				</view>
				<view class="ul" v-for="item in orderList" :key="item.id">
					<div class="li">
						<div class="name">订单ID：</div>
						<div class="contentValue">{{ item.id }}</div>
					</div>
					<div class="li">
						<div class="name">商品金额：</div>
						<div class="contentValue">{{ item.total_amount }}</div>
					</div>
					<div class="li">
						<div class="name">商品名称：</div>
						<div class="contentValue">{{ item.goodname }}</div>
					</div>
					<div class="li">
						<div class="name">支付方式：</div>
						<div class="contentValue">{{
							item.pay_way == 1 ? '微信支付' : item.pay_way == 2 ? '余额支付' : item.pay_way
								== 3
								? "余额组合支付" : item.pay_way == 4 ? '直播红包支付' : item.pay_way == 5 ? '直播红包组合支付' : ''
						}}</div>
					</div>
					<div class="li">
						<div class="name">微信支付金额：</div>
						<div class="contentValue">{{ item.wx_pay_num }}</div>
					</div>
					<div class="li">
						<div class="name">余额支付金额：</div>
						<div class="contentValue">{{ item.money_pay_num }}</div>
					</div>
					<div class="li">
						<div class="name">直播红包支付金额：</div>
						<div class="contentValue">{{ item.red_pay_num }}</div>
					</div>
					<div class="li">
						<div class="name">优惠方式：</div>
						<div class="contentValue">
							{{ item.discount_type
								== 0 ? '无' : item.discount_type == 1
								? '优惠劵' : item.discount_type == 2 ? '积分抵扣' : ''
									|| '-' }}
						</div>
					</div>
					<div class="li">
						<div class="name">抵扣积分：</div>
						<div class="contentValue">{{ item.integral_discount_num }}</div>
					</div>
					<div class="li">
						<div class="name">优惠券红包：</div>
						<div class="contentValue">{{ item.coupon_fee }}</div>
					</div>
					<div class="li">
						<div class="name">下单人：</div>
						<div class="contentValue">{{ item.nickname }}</div>
					</div>
					<div class="li">
						<div class="name">下单手机号：</div>
						<div class="contentValue">{{ item.mobile }}</div>
					</div>
					<div class="li">
						<div class="name">收货人：</div>
						<div class="contentValue">{{ item.consignee }}</div>
					</div>
					<div class="li">
						<div class="name">收货手机号：</div>
						<div class="contentValue">{{ item.consignee_mobile }}</div>
					</div>
					<div class="li">
						<div class="name">订单状态：</div>
						<div class="contentValue">{{
							item.order_status == 0 ? '待付款' : item.order_status == 1 ? '待发货' : item.order_status
								== 2
								? "拣货中" : item.order_status == 3 ? '已发货' : item.order_status == 4 ? '售后' :
									item.order_status == 5 ? '自动取消' : ''
						}}</div>
					</div>
					<div class="li">
						<div class="name">支付时间：</div>
						<div class="contentValue">{{ item.pay_time }}</div>
					</div>
					<div class="li">
						<div class="name">支付方式：</div>
						<div class="contentValue">
							{{
								item.pay_way == 1 ? '微信支付' : item.pay_way == 2 ? '余额支付' : item.pay_way == 3
									? '组合支付'
									: ''
							}}
						</div>
					</div>
					<div class="li liTwo">
						<div class="name">总订单编号：</div>
						<div class="contentValue">{{ item.order_sn }}<view class="duplicate"
								@click="copyOrderId(item.order_sn)">复制</view>
						</div>
					</div>
					<div class="li liTwo">
						<div class="name">子订单编号：</div>
						<div class="contentValue">{{ item.sub_order_sn }}<view class="duplicate"
								@click="copyOrderId(item.sub_order_sn)">复制</view>
						</div>
					</div>
					<div class="li liTwo">
						<div class="name">快递单号：</div>
						<div class="contentValue">{{ item.express_num }}<view class="duplicate" v-if="item.express_num"
								@click="copyOrderId(item.express_num)">复制</view>
						</div>
					</div>
					<div class="li liTwo">
						<div class="name">收货地址：</div>
						<div class="contentValue">
							{{ item.consignee }} {{ item.consignee_mobile }} {{ item.province }}{{ item.city }}{{
								item.district }}{{ item.address }}
							<view class="duplicate" @click="copy(item)">复制</view>
						</div>
					</div>
					<div class="li liTwo" v-if="item.refund_status != 0">
						<div class="name">售后金额：</div>
						<div class="contentValue">
							{{ item.refund_amount }}
						</div>
					</div>


					<view class="btnBox liTwo">
						<view class="btn" v-if="(item.pay_status == 1 && item.refund_status != 2)">
							<u-button @click="on_operate(1, item)" type="error" text="退款"></u-button>
						</view>
						<view class="btn" v-if="(item.order_status == 1 || item.order_status == 2)">
							<u-button @click="on_operate(2, item)" type="primary" text="发货"></u-button>
						</view>
					</view>
				</view>
			</view>
			<view v-if="pageIndex == 1">
				<view class="inputValueBox">
					<u--input focus v-model="valueData" customStyle="background: #fff;" @confirm="on_confirm(2)"
						shape="circle" border="true" :adjustPosition="false" fontSize="14px"
						placeholder="用户ID/收货人手机号/子订单号/物流单号/订单ID" prefixIcon="search"
						prefixIconStyle="font-size: 22px;color: #0000000;font-weight: 700;" />
				</view>
				<view>
					<view class="ul" v-for="item in orderList" :key="item.id">
						<div class="li">
							<div class="name">订单ID：</div>
							<div class="contentValue">{{ item.id }}</div>
						</div>
						<div class="li">
							<div class="name">退款金额：</div>
							<div class="contentValue">{{ item.refund_price }}
							</div>
						</div>
						<div class="li">
							<div class="name">退款方式：</div>
							<div class="contentValue">
								{{
									item.refund_way == 1 ? '微信' : item.refund_way == 2 ? '余额' : item.refund_way == 3 ? '积分'
										: '-'
								}}
							</div>
						</div>
						<div class="li">
							<div class="name">操作人：</div>
							<div class="contentValue">{{ item.real_name }}</div>
						</div>
						<div class="li">
							<div class="name">操作类型：</div>
							<div class="contentValue">{{ item.is_handle }}</div>
						</div>
						<div class="li liTwo">
							<div class="name">订单编号：</div>
							<div class="contentValue">{{ item.sub_order_sn }}</div>
						</div>
						<div class="li liTwo">
							<div class="name">快递单号：</div>
							<div class="contentValue">{{ item.express_num }}</div>
						</div>
						<div class="li liTwo">
							<div class="name">退款时间：</div>
							<div class="contentValue">{{ item.refund_time }}</div>
						</div>
					</view>
				</view>
			</view>
			<view v-if="pageIndex == 2">
				<view class="inputValueBox">
					<u--input focus v-model="valueDataThree" customStyle="background: #fff;" @confirm="on_confirm(3)"
						shape="circle" border="true" :adjustPosition="false" fontSize="14px" placeholder="搜索订单号"
						prefixIcon="search" prefixIconStyle="font-size: 22px;color: #0000000;font-weight: 700;" />
				</view>
				<view v-if="wxOrderInfo">
					<view class="block" v-if="wxOrderInfo.user">
						<view class="title">用户信息</view>
						<div class="li">
							<div class="name">用户id：</div>
							<div class="contentValue">{{ wxOrderInfo.user.id || '-' }}</div>
						</div>
						<div class="li">
							<div class="name">用户昵称：</div>
							<div class="contentValue">{{ wxOrderInfo.user.nickname || '-' }}</div>
						</div>
						<div class="li">
							<div class="name">用户手机号：</div>
							<div class="contentValue">{{ wxOrderInfo.user.mobile || '-' }}</div>
						</div>
					</view>
					<view class="block" v-if="wxOrderInfo.address">
						<view class="title">地址信息</view>
						<div class="li">
							<div class="name">收货人姓名：</div>
							<div class="contentValue">{{ wxOrderInfo.address.address_info.user_name || '-' }}</div>
						</div>
						<div class="li">
							<div class="name">收货人地址：</div>
							<div class="contentValue">{{ wxOrderInfo.address.address_info.province_name +
								wxOrderInfo.address.address_info.city_name +
								wxOrderInfo.address.address_info.county_name +
								wxOrderInfo.address.address_info.detail_info || '-' }}</div>
						</div>
						<div class="li">
							<div class="name">收货人手机号：</div>
							<div class="contentValue">{{ wxOrderInfo.address.address_info.tel_number || '-' }}</div>
						</div>
					</view>
					<view class="block">
						<view class="title">物流信息</view>
						<view class="ul" v-for="item in wxOrderInfo.address.delivery_product_info" :key="item.sku_id">
							<div class="li">
								<div class="name">快递：</div>
								<div class="contentValue">{{ item.delivery_name }}</div>
							</div>
							<div class="li">
								<div class="name">单号：</div>
								<div class="contentValue">{{ item.waybill_id }}
								</div>
							</div>
						</view>
					</view>

					<view class="block" v-if="wxOrderInfo.share">
						<view class="title">分享员信息</view>
						<div class="li">
							<div class="name">分享员id：</div>
							<div class="contentValue">{{ wxOrderInfo.share.id || '-' }}</div>
						</div>
						<div class="li">
							<div class="name">分享员姓名：</div>
							<div class="contentValue">{{ wxOrderInfo.share.nickname || '-' }}</div>
						</div>
						<div class="li">
							<div class="name">分享员手机号：</div>
							<div class="contentValue">{{ wxOrderInfo.share.mobile || '-' }}</div>
						</div>
					</view>
					<view class="block">
						<view class="title">商品信息</view>
						<view class="ul" v-for="item in wxOrderInfo.goods" :key="item.sku_id">
							<div class="li">
								<div class="name">商品图片：</div>
								<div class="contentValue">
									<image :src="item.thumb_img" class="img" />
								</div>
							</div>
							<div class="li">
								<div class="name">商品名称：</div>
								<div class="contentValue">{{ item.title }}
								</div>
							</div>
							<div class="li">
								<div class="name">商品规格：</div>
								<div class="contentValue">{{ item.sku_attrs[0].attr_value }}</div>
							</div>
							<div class="li">
								<div class="name">商品价格：</div>
								<div class="contentValue">￥{{ item.market_price / 100 }}</div>
							</div>
						</view>
					</view>
				</view>
			</view>
			<view v-if="pageIndex == 3">
				<view class="inputValueBox">
					<u--input focus v-model="valueDataFour" customStyle="background: #fff;" @confirm="on_confirm(4)"
						shape="circle" border="true" :adjustPosition="false" fontSize="14px" placeholder="搜索订单号/快递单号"
						prefixIcon="search" prefixIconStyle="font-size: 22px;color: #0000000;font-weight: 700;" />
				</view>
				<view class="ul" v-for="item in orderList" :key="item.id">
					<div class="li">
						<div class="name">订单ID：</div>
						<div class="contentValue">{{ item.id }}</div>
					</div>
					<div class="li">
						<div class="name">商品ID：</div>
						<div class="contentValue">{{ item.goods_id }}</div>
					</div>
					<div class="li">
						<div class="name">商品名称：</div>
						<div class="contentValue">{{ item.goods_name }}</div>
					</div>
					<div class="li">
						<div class="name">商品规格：</div>
						<div class="contentValue">{{ item.goods_style }}</div>
					</div>

					<div class="li">
						<div class="name">店铺ID：</div>
						<div class="contentValue">{{ item.shop_id }}</div>
					</div>
					<div class="li">
						<div class="name">店铺名称：</div>
						<div class="contentValue">{{ item.shop_name }}</div>
					</div>
					<div class="li">
						<div class="name">联系人：</div>
						<div class="contentValue">{{ item.contacts }}</div>
					</div>
					<div class="li">
						<div class="name">联系方式：</div>
						<div class="contentValue">{{ item.contacts_mobile }}</div>
					</div>
					<div class="li liTwo">
						<div class="name">店铺地址：</div>
						<div class="contentValue">{{ item.address }}</div>
					</div>
					<div class="li">
						<div class="name">数量：</div>
						<div class="contentValue">{{ item.num }}</div>
					</div>
					<div class="li">
						<div class="name">进货单价：</div>
						<div class="contentValue">{{ item.goods_price }}</div>
					</div>
					<!-- <div class="li">
						<div class="name">订单总价：</div>
						<div class="contentValue">{{ item.total_price }}</div>
					</div> -->
					<div class="li">
						<div class="name">支付状态：</div>
						<div class="contentValue">
							{{
								item.pay_status == 0 ? '待支付' : item.pay_status == 1 ? '已支付' : item.pay_status == 2
									? '已退款'
									: ''
							}}
						</div>
					</div>
					<div class="li">
						<div class="name">订单状态：</div>
						<div class="contentValue">{{
							item.order_status == 1 ? '待发货' : item.order_status
								== 2
								? "拣货中" : item.order_status == 3 ? '已发货' : item.order_status == 4 ? '已收货' :
									item.order_status == 5 ? '已退款' : ''
						}}</div>
					</div>
					<div class="li">
						<div class="name">类型：</div>
						<div class="contentValue">
							{{
								item.shop_level == 1 ? '总店进货' : item.shop_level == 2 ? '分店进货' : ''
							}}
						</div>
					</div>
					<div class="li">
						<div class="name">进货时间：</div>
						<div class="contentValue">{{ item.pay_time }}</div>
					</div>

					<div class="li liTwo">
						<div class="name">总订单编号：</div>
						<div class="contentValue">{{ item.order_sn }}<view class="duplicate"
								@click="copyOrderId(item.order_sn)">复制</view>
						</div>
					</div>
					<div class="li liTwo">
						<div class="name">子订单编号：</div>
						<div class="contentValue">{{ item.sub_order_sn }}<view class="duplicate"
								@click="copyOrderId(item.sub_order_sn)">复制</view>
						</div>
					</div>

					<div class="li liTwo" v-if="item.pay_status == 1 && item.refund_amount">
						<div class="name">售后金额：</div>
						<div class="contentValue">
							{{ item.refund_amount }}
						</div>
					</div>

					<view class="btnBox liTwo">
						<view class="btn" v-if="item.pay_status == 1">
							<u-button @click="on_operate(1, item)" type="error" text="售后"></u-button>
						</view>
					</view>
				</view>
			</view>


			<view class="pagination" v-if="total">
				<uni-pagination @change="on_change" :total="total"></uni-pagination>
				<view class="example">
					<text class="example-info">当前页：{{ page }}，数据总量：{{ total }}条，每页数据：{{ 10 }}</text>
				</view>
			</view>

			<view v-if="orderList.length <= 0 && pageIndex != 2" class="noData">请搜索数据</view>

		</view>

		<u-modal @confirm="on_defineOperation(1)" @cancel="showType = false" :showCancelButton="true" :show="showType"
			title="发货信息">
			<view class="slot-content">
				<view class="selectBox">
					<view class="name">支持快递：</view>
					<view class="select">
						<uni-data-select v-model="typeForm.value1" :localdata="expressList"></uni-data-select>
					</view>
				</view>

				<view class="selectBox">
					<view class="name">快递单号：</view>
					<view class="select">
						<u--input placeholder="请输入快递单号" border="surround" v-model="typeForm.value2"></u--input>
					</view>
				</view>
			</view>
		</u-modal>


		<u-modal @confirm="on_defineOperation(2)" @cancel="showType1 = false" :showCancelButton="true" :show="showType1"
			title="退款">
			<view class="slot-content">
				<view v-if="pageIndex != 3" style="color:red;font-size:12px">注意：组合支付全部退回余额，当前{{ form.pay_way == 1 ?
					'微信支付'
					: form.pay_way == 2
						?
						'余额支付'
						:
						form.pay_way == 3 ? '组合支付' : '' }}
				</view>

				<view class="selectBox">
					<view class="name">退款方式：</view>
					<view class="select">
						<u-radio-group v-model="form.type" placement="row">
							<u-radio class="radio" v-for="(item, index) in radiolist" :key="index" :label="item.name"
								:name="item.name" @change="radioChange">
							</u-radio>
						</u-radio-group>
					</view>
				</view>

				<view class="selectBox" v-if="form.type == '取消订单' && pageIndex != 3">
					<view class="name">是否退还积分：</view>
					<view class="select">
						<u-radio-group v-model="form.is_refund" placement="row">
							<u-radio class="radio" v-for="(item, index) in radiolistTwo" :key="index" :label="item.name"
								:name="item.name">
							</u-radio>
						</u-radio-group>
					</view>
				</view>

				<!-- <view class="selectBox">
					<view class="name">退款理由：</view>
					<view class="select">
						<uni-data-select v-model="form.refund_reason_type" :localdata="rangeTwo"></uni-data-select>
					</view>
				</view>

				<view class="selectBox">
					<view class="name">退款原因：</view>
					<view class="select">
						<u--textarea v-model="form.refund_reason" placeholder="如: 山竹坏掉3个"></u--textarea>
					</view>
				</view> -->


				<view class="selectBox" v-if="form.type == '售后理赔'">
					<view class="name">退款金额：</view>
					<view class="select">
						<u--input placeholder="请输入退款金额" border="surround" v-model="form.money"></u--input>
					</view>
				</view>
			</view>
		</u-modal>

		<u-loading-page loading-color="#1890ff" color="#fff" bg-color="rgba(0, 0, 0, 0.5)" :loading="loadingType">
		</u-loading-page>
	</view>
</template>

<script>
export default {
	data() {
		return {
			expressList: [],
			loadingType: false,
			rangeTwo: [{
				text: '快递管控取消订单',
				value: '快递管控取消订单',
			},
			{
				text: '快递异常售后退全款',
				value: '快递异常售后退全款',
			}, {
				text: '坏果按个理赔',
				value: '坏果按个理赔',
			}
			],
			radiolistTwo: [{
				name: '是'
			},
			{
				name: '否'
			}
			],
			radiolist: [{
				name: '售后理赔'
			},
			{
				name: '取消订单'
			}

			],
			showType1: false,
			form: {
				money: '',
				type: '取消订单',
				is_refund: '是',
				// refund_reason_type: '其它'
			},
			typeForm: {
				value1: "",
				value2: ""
			},
			showType: false,
			valueDataTwo: '',
			valueData: '',
			valueDataThree: '',
			valueDataFour: '',
			// MS202509081200382364715492
			pageIndex: 0,
			list: [{
				name: '普通订单'
			},
			{
				name: '售后订单'
			},
			{
				name: '站外订单'
			},
			{
				name: '进货订单'
			}
			],
			total: 0,
			page: 1,
			orderList: [],
			orderId: '',
			showBtn: true, //可点击状态
			pageIndex: 0,
			wxOrderInfo: {
				user: {},
				goods: [],
				address: {
					address_info: {},
					delivery_product_info: []
				},
				share: {},
			},
		};
	},
	onShow() {
		if (this.pageIndex == 0) {
			this.ajax_orderList()
		} else if (pageIndex == 1) {
			this.ajax_afterSalesList()
		} else if (pageIndex == 2) {
			this.ajax_getWxorderInfo()
		}
		else if (this.pageIndex == 3) {
			this.ajax_purchaseOrderList()
		}
	},
	onLoad() {
		this.ajax_expressList()
	},
	methods: {
		//复制订单号
		copyOrderId(oid) {
			var that = this;
			uni.setClipboardData({
				data: oid,
				success: function () {
					that.$showToast('复制成功')
				}
			});
		},
		copy(item) {
			var that = this;
			var content = item.consignee + ' ' + item.consignee_mobile + ' ' + item.province + item.city + item.district + item.address
			uni.setClipboardData({
				data: content,
				success: function () {
					that.$showToast('复制成功')
				}
			});
		},
		on_confirm(index) {
			if (index == 1) {
				this.ajax_orderList()
			}
			if (index == 2) {
				this.ajax_afterSalesList()
			}
			if (index == 3) {
				this.ajax_getWxorderInfo()
			}
			if (index == 4) {
				this.ajax_purchaseOrderList()
			}
		},
		ajax_getWxorderInfo() {
			if (!this.valueDataThree) {
				uni.showToast({
					title: '请输入订单号',
					icon: 'none'
				})
			} else {
				this.loadingType = true;
				this.$request.request({
					url: 'WxStore/getWxorderInfo',
					method: 'GET',
					data: {
						orderId: this.valueDataThree
					}
				}).then(res => {
					this.wxOrderInfo = res.data.data
				}).finally(() => {
					this.loadingType = false;
				})
			}
		},
		// 快递列表
		ajax_expressList() {
			this.$request.request({
				url: 'setting.express/all',
				method: 'POST',
			}).then(res => {
				res.data.list.forEach(item => {
					item.value = item.express_name;
					item.text = item.express_name;
				})
				this.expressList = res.data.list
			}).finally(() => { })
		},
		// 售后订单
		ajax_afterSalesList() {
			this.loadingType = true;
			this.$request.request({
				url: 'mobile/afterSalesOrder',
				method: 'POST',
				data: {
					page: this.page,
					value: this.valueData
				}
			}).then(res => {
				this.orderList = res.data.data.data
				this.total = res.data.data.total
			}).finally(() => {
				this.loadingType = false;
			})
		},
		// 全部订单
		ajax_orderList() {
			this.loadingType = true;
			this.$request.request({
				url: 'mobile/OrderMsg',
				method: 'POST',
				data: {
					page: this.page,
					value: this.valueDataTwo
				}
			}).then(res => {
				this.orderList = res.data.data.data
				this.total = res.data.data.total
			}).finally(() => {
				this.loadingType = false;
			})
		},
		// 进货订单
		ajax_purchaseOrderList() {
			this.loadingType = true;
			this.$request.request({
				url: 'Mobile/shopSubPurchaseOrderList',
				method: 'POST',
				data: {
					page: this.page,
					value: this.valueDataFour
				}
			}).then(res => {
				this.orderList = res.data.list.data
				this.total = res.data.list.total
			}).finally(() => {
				this.loadingType = false;
			})
		},
		on_change(page) {
			this.page = page.current;
			if (this.pageIndex == 0) {
				this.ajax_orderList()
			} else if (this.pageIndex == 1) {
				this.ajax_afterSalesList()
			} else if (this.pageIndex == 2) {
				this.ajax_getWxorderInfo()
			}
			else if (this.pageIndex == 3) {
				this.ajax_purchaseOrderList()
			}
		},
		radioChange(e) {
		},
		on_defineOperation(index) {
			if (!this.showBtn) {
				return false;
			}
			this.showBtn = false;
			if (index == 1) {
				if (!this.typeForm.value1) {
					uni.showToast({
						title: '请选择支持快递',
						icon: 'none'
					})
				} else if (!this.typeForm.value2) {
					uni.showToast({
						title: '请输入快递单号',
						icon: 'none'
					})
				} else {
					uni.showLoading({
						title: '加载中···',
						mask: true
					})
					this.$request.request({
						url: 'order/oneOederDeliver',
						method: 'POST',
						data: {
							id: this.orderId,
							express_company: this.typeForm.value1,
							express_num: this.typeForm.value2,
						}
					}).then(res => {
						this.showType = false;
						this.ajax_orderList()
						uni.showToast({
							title: '操作成功',
							icon: 'none'
						})
						uni.hideLoading()
						setTimeout(() => {
							this.showBtn = true;
						}, 3000)
					}).finally(() => {

					})
				}
			}
			if (index == 2) {
				console.log(this.pageIndex, '点击售后确定')
				if (this.pageIndex != 3) {
					console.log('进入普通订单售后')
					if (this.form.type == '取消订单') {
						uni.showLoading({
							title: '加载中···',
							mask: true
						})
						this.$request.request({
							url: 'order/orderRefund',
							method: 'POST',
							data: {
								sub_order_sn: this.form.sub_order_sn,
								money: this.form.money,
								type: this.form.type == '取消订单' ? '1' : '2',
								is_refund: this.form.is_refund == '是' ? '1' : '2',
								// refund_reason_type: this.form.refund_reason_type,
								// refund_reason: this.form.refund_reason,
							}
						}).then(res => {
							this.showType1 = false;
							this.ajax_orderList()
							uni.showToast({
								title: '操作成功',
								icon: 'none'
							})
							uni.hideLoading()
							setTimeout(() => {
								this.showBtn = true;
							}, 3000)
						}).finally(() => {

						})
					} else if (this.form.type == '售后理赔') {
						if (!this.form.money) {
							uni.showToast({
								title: '请输入退款金额',
								icon: 'none'
							})
						} else {
							uni.showLoading({
								title: '加载中···',
								mask: true
							})
							this.$request.request({
								url: 'order/orderRefund',
								method: 'POST',
								data: {
									sub_order_sn: this.form.sub_order_sn,
									money: this.form.money,
									type: this.form.type == '取消订单' ? '1' : '2',
									is_refund: this.form.is_refund == '是' ? '1' : '2',
									// refund_reason_type: this.form.refund_reason_type,
									// refund_reason: this.form.refund_reason,
								}
							}).then(res => {
								this.showType1 = false;
								this.ajax_orderList()
								uni.showToast({
									title: '操作成功',
									icon: 'none'
								})
								uni.hideLoading()
								setTimeout(() => {
									this.showBtn = true;
								}, 3000)
							}).finally(() => {

							})
						}
					}
				}

				// 进货订单售后
				else {

					console.log(this.form, 111)
					if (!this.form.money && this.form.type == '售后理赔') {
						uni.showToast({
							title: '请输入退款金额',
							icon: 'none'
						})
						return;
					}

					console.log('进入进货订单售后')
					uni.showLoading({
						title: '加载中···',
						mask: true
					})
					this.$request.request({
						url: 'shop/refundPurchaseOrder',
						method: 'POST',
						data: {
							type: this.form.type == '取消订单' ? '1' : '2',
							sub_order_sn: this.form.sub_order_sn,
							price: this.form.money,
						}
					}).then(res => {
						this.showType1 = false;
						this.ajax_purchaseOrderList()
						uni.showToast({
							title: '操作成功',
							icon: 'none'
						})
						uni.hideLoading()
						setTimeout(() => {
							this.showBtn = true;
						}, 3000)
					}).finally(() => {

					})

				}

			}
		},
		on_operate(index, item) {
			this.orderId = item.id
			if (index == 1) {
				this.form.money = '';
				this.form.type = '售后理赔';
				this.form.sub_order_sn = item.sub_order_sn;
				this.form.pay_way = item.pay_way;
				this.form.money_pay_num = item.money_pay_num;
				this.form.wx_pay_num = item.wx_pay_num;
				// this.form.refund_reason_type = '其它'
				// this.form.refund_reason = ''
				this.showType1 = true
				// uni.navigateTo({
				// 	url: '/pages/ASWorkbench?order=' + item.sub_order_sn
				// })
			}
			if (index == 2) {
				this.showType = true
			}
		},
		on_tab(e) {
			this.page = 1;
			if (e.index == 0) {
				this.ajax_orderList()
			} else if (e.index == 1) {
				this.ajax_afterSalesList()
			} else if (e.index == 2) {
				this.ajax_getWxorderInfo()
			} else if (e.index == 3) {
				this.ajax_purchaseOrderList()
			}
			this.pageIndex = e.index
		},
	},
};
</script>
<style lang="scss" scoped>
.orderManagement {
	.slot-content {
		width: 100% !important;

		.selectBox {
			// display: flex;
			// align-items: center;
			font-size: 14px;
			margin-top: 30rpx;

			.name {
				white-space: normal nowrap;
				margin-bottom: 20rpx;
			}

			.select {
				flex: 1;

				.radio:nth-child(1) {
					margin-left: 0;
				}

				.radio {
					margin-left: 40rpx;
				}
			}
		}
	}

	.content {
		padding: 20rpx;

		.ul:nth-last-child(1) {
			border-bottom: none;
		}

		.block {
			margin-top: 15rpx;
			width: 100%;
			font-size: 14px;
			padding: 20rpx;
			padding-bottom: 20rpx;
			border: 1px solid #ccc;

			.title {
				font-size: 15px;
				font-weight: 700;
			}

			.li {
				margin-top: 20rpx;
				width: 50%;
			}
		}

		.ul {
			width: 100%;
			display: flex;
			flex-wrap: wrap;
			font-size: 14px;
			border-bottom: 1px solid #ccc;
			padding-bottom: 20rpx;

			.li {
				margin-top: 20rpx;
				width: 50%;

				.img {
					width: 100rpx;
					height: 100rpx;
				}

				.contentValue {
					margin-top: 6rpx;

					.duplicate {
						color: #999999;
						font-size: 22rpx;
						border: 2rpx solid #999999;
						border-radius: 8rpx;
						padding: 2rpx 8rpx;
						margin-left: 20rpx;
						float: right;
					}
				}
			}

			.liTwo {
				width: 100% !important;
			}

			.btnBox {
				display: flex;
				margin-top: 20rpx;
				max-width: 100%;
				flex-wrap: wrap;
				justify-content: space-between;

				.btn {
					// margin-top: 20rpx;
					margin: 10rpx;
					min-width: 30%;
				}
			}
		}
	}
}
</style>
